import {Observable} from "rxjs/Observable";
import 'rxjs/add/observable/of';


export class HttpMock {
  post() {
    return Observable.of();
  }

  put() {
    return Observable.of();
  }

  get() {
    return Observable.of();
  }

  delete(url) {
    return Observable.of();
  }
}

export class HttpServiceMock {
  get() {
    return Observable.of();
  }

  post() {
    return Observable.of();
  }

  put() {
    return Observable.of();
  }

  delete() {
    return Observable.of();
  }
}

export class DomSanitizerMock {
  sanitize() {
    return;
  }

  bypassSecurityTrustUrl(url) {
    return url;
  }
}

export class UtilsServiceMock {
  getVerifyCode() {
    return Observable.of({
      data: {
        pic: "picture-url",
        codeCipher: "abcd"
      }
    });
  }

  getUserRole() {
    return Promise.resolve('普通用户');
  }

  popMessage() {
    return {
      onDidDismiss: function (func) {

      },
      dismiss: function () {
        return new Promise((resolve: Function) => {
          resolve();
        });
      },
      present: function () {
        return new Promise((resolve: Function) => {
          resolve();
        });
      }
    }
  }

  popPicker(dataArr, cssClass, successFn) {
    let c = {};
    dataArr.forEach((item) => {
      let name = item['name'];
      c[name] = {
        text: 'test',
        value: 'test'
      };
    });
    successFn(c);
    return {
      onDidDismiss: function (func) {

      },
      dismiss: function () {
        return new Promise((resolve: Function) => {
          resolve();
        });
      },
      present: function () {
        return new Promise((resolve: Function) => {
          resolve();
        });
      }
    }
  }

  popConfirm(title: string, message: string, cancelCallback: any, confirmCallback: any) {
    confirmCallback();
  }

  popPrompt(title: string, message: string) {
  }


  popLoading() {
    return {
      onDidDismiss: function (func) {

      },
      dismiss: function () {
        return new Promise((resolve) => {
          resolve();
        });
      },
      present: function() {
        return new Promise((resolve) => {
          resolve();
        });
      }
    }
  }

  localeDateTime() {
  }

  getPermission() {
    return {
      visitor: 'visitor',
      employee: 'employee',
      secretary: 'secretary',
      approver: 'approver',
      canteen_manager: 'canteen_manager',
      property_manager: 'property_manager'
    };

  }

  showTip(showInfo: any = {
            resultFlag: true,
            message: ''
          },
          showConfig: any = {
            hiddenTimeOut: 500,
            autoClose: true,
            onDismiss: null
          }) {
    if (showConfig.onDismiss) {
      showConfig.onDismiss();
    }
  }
}

export class EncryptMock {
  encrypt() {
    return "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC17FLv5hSH2WW2Jv2j50b0Ihka9UhkP7MuWOdA"
  }
  encryptToken(str) {
    return "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC17FLv5hSH2WW2Jv2j50b0Ihka9UhkP7MuWOdA"
  }

  decryptToken(str) {
    return "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC17FLv5hSH2WW2Jv2j50b0Ihka9UhkP7MuWOdA"
  }

  getPublicKey() {
    return "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC17FLv5hSH2WW2Jv2j50b0Ihka9UhkP7MuWOdA\n" +
      "9Xi6/3rQC5C/hmhyLX8h/8Q2ObWkGZ036VI8TSUCH5AiLF3Mhb2IoBHATN7ltdOlZ07yG4yoVspU\n" +
      "R0sE7LaiEfGmO6SHH50ulUL7ggphZpzjW4L/8J+Cg2amqI57Fw6XVR9NrwIDAQAB";
  }
}

export class ConfigMock {
  getEndpoint() {
    return "";
  }

  setModeConfig() {
    return "";
  }

  get() {

  }

  getBoolean() {

  }
}

export class ImageServiceMock {
  pickOrTakePhotoThenUpload(data: string) {
    return new Promise(((reslove) => {
      reslove({state: 1, data: {serveResponse: {attachmentId: '', thumbnailId: ''}, srcImg: ''}});
    }));
  }

  uploadImageFile(data: any) {
    return new Promise((resolve) => {
      resolve();
    });
  }

  getImage(data: any) {
    return new Promise((resolve) => {
      resolve();
    });
  }

  initAttachmentArray(src1: any, src2: any) {
    return [];
  }

  wrapAttachmentThumbnail(arrayData: any) {
    return;
  }
}



